﻿using RBAC.ErrorCode;
using RBAC.Host.Dto.Input;
using RBAC.Host.Dto.Output;

namespace RBAC.Host.Service
{
    public interface IService
    {
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        APIResult<int> AddPermission(AddPermissionInput input);

        /// <summary>
        /// 权限列表
        /// </summary>
        /// <returns></returns>
       APIResult< List<PermissionDto>> GetPermissionList(string? permissionName);
        /// <summary>
        /// 角色列表
        /// </summary>
        /// <returns></returns>
        APIResult<List<RoleListDto>> GetRoleList(string? roleName);

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        APIResult<UserLoginDto> UserLogin(UserLoginInputDto input);

        // 用户管理
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        APIResult<List<UserDto>> GetUserList(string? userName = null);
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        APIResult<UserDto> GetUser(long id);
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="userDto"></param>
        /// <returns></returns>
        APIResult<int> AddUser(UserDto userDto);
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="userDto"></param>
        /// <returns></returns>
        APIResult<int> UpdateUser(UserDto userDto);
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        APIResult<int> DeleteUser(long id);

        // 角色管理
        /// <summary>
        /// 获取角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        APIResult<RoleListDto> GetRole(long id);
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="roleDto"></param>
        /// <returns></returns>
        APIResult<int> AddRole(RoleDto roleDto);
        /// <summary>
        /// 修改角色
        /// </summary>
        /// <param name="roleDto"></param>
        /// <returns></returns>
        APIResult<int> UpdateRole(RoleDto roleDto);
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        APIResult<int> DeleteRole(long id);

        // 权限管理
        /// <summary>
        /// 获取权限
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        APIResult<PermissionDto> GetPermission(long id);
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="permissionDto"></param>
        /// <returns></returns>
        APIResult<int> AddPermission(PermissionDto permissionDto);
        /// <summary>
        /// 修改权限
        /// </summary>
        /// <param name="permissionDto"></param>
        /// <returns></returns>
        APIResult<int> UpdatePermission(PermissionDto permissionDto);
        /// <summary>
        /// 删除权限
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        APIResult<int> DeletePermission(long id);

        // 用户角色分配
        APIResult<int> AssignRoleToUser(long userId, long roleId);
        /// <summary>
        /// 移除用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        APIResult<int> RemoveRoleFromUser(long userId, long roleId);
        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        APIResult<List<RoleListDto>> GetUserRoles(long userId);

        // 角色权限分配
        /// <summary>
        /// 角色权限分配
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="permissionId"></param>
        /// <returns></returns>
        APIResult<int> AssignPermissionToRole(long roleId, long permissionId);
        /// <summary>
        /// 移除角色权限
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="permissionId"></param>
        /// <returns></returns>
        APIResult<int> RemovePermissionFromRole(long roleId, long permissionId);
        /// <summary>
        /// 获取角色权限
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        APIResult<List<PermissionDto>> GetRolePermissions(long roleId);

        /// <summary>
        /// 查询用户所有权限
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        APIResult<List<PermissionDto>> GetUserPermissions(long userId);
    }
}
